#!/bin/bash

INDIR=$1
OUTDIR=$2
ERRORS=0

for fn in $INDIR/*.cg
do
	name=`basename $fn .cg`
	echo "Converting $fn -> $OUTDIR/$name.glsl"
	cgc -ogles -C -profile glslf -profileopts version=120,userTexCoord=v_texCoord -o "$OUTDIR/$name.glsl" -entry main_fragment "$fn"
	if [ $? != 0 ]; then
		echo "Fail"
		ERRORS=`expr $ERRORS + 1`
	fi
	#echo $name
done;

# remove HD ones from cellframework
rm *HD*

echo "Completed with $ERRORS errors."
